# 对list进行切片，从1开始，4结束，步长1
my_list = [0, 1, 2, 3, 4, 5, 6]
new_my_list = my_list[1:4:1]
print(new_my_list)

# 对tuple进行切片，从头开始，到最后结束，步长1
my_tuple = (0, 1, 2, 3, 4, 5, 6)
new_my_tuple = my_tuple[:]  #起始和结束不写表示从头到尾，步长为1可以省略
print(new_my_tuple)

# 对str进行切片，从头开始，到最后结束，步长2
my_str = "0123456"
new_my_str = my_str[::2]
print(new_my_str)

# 对str进行切片，从头开始，到最后结束，步长-1
my_str = "0123456"
result1 = my_str[::-1]  #等同于将序列反转
print(result1)

# 对str进行切片，从3开始，到1结束，步长-1
my_str = "0123456"
result2 = my_str[3:1:-1]
print(result2)

# 对tuple进行切片，从头开始，到最后结束，步长-2
my_tuple = (0, 1, 2, 3, 4, 5, 6)
result3 = my_tuple[::-2]
print(result3)